package cn.fengzhilun.javase.day06;

import org.junit.Test;

public class TestExtends {
	 @Test
	 public void test1() {
		 Programmer p= new Programmer();
		 p.coding();
		 p.setName("码农");
		 
	 }
	 @Test
	 public void test2() {
		 // 子类会继承父类public 方法
		 // 子类会继承父类所有的属性属性和方法，只是对外不可见而已。
		Programmer p = new Programmer();
		p.setSalary(10000);
		
		Manager manager =new Manager();
		manager.setSalary(12000);
		manager.setBonus(5000);
		
		System.out.println(p.getSalary());
		System.out.println(manager.getSalary());
		 
	 }
	 @Test
	 public void test3() {
		 Manager manager=new Manager();
		 manager.setSalary(12000);
		 manager.setBonus(5000);
		 
	 }
	 @Test
	 public void test4() {
		 
		 new Programmer();
	 }
	 @Test
		public void test5() {
			Programmer p=new Programmer();
			//多态不能调用子类的特有的方法
			Employee e1=new Programmer();
			Employee e2=new Programmer();
			//e2.coding();
			//(Programmer)(e2).coding();
			((Programmer)(e2)).coding();

			Programmer p1=(Programmer)e1;
			p1.coding();
			
		}
	 @Test
	 public  void test6() {
		 //
		 Employee e1 =new Manager();
		 System.out.println(e1.getSalary());
		 
	 }
	 @Test
	 public void test7() {
		 Programmer p=new Programmer();	 
		 p.setSalary(10000);
		
		 Manager m =new Manager();
		 m.setSalary(12000);
		 m.setBonus(5000);
		 
		 //利用多态来调用其他的方法
		 Boss boss=new Boss();
		 boss.pay(p);
		 boss.pay(m);
		 
		 
	 }
	 @Test
	 public void test11() {
		 Employee e1=new Employee();
		 Employee e2 =new Employee();
		 
		 System.out.println(e1 instanceof Object);
		 
		 String s1=new String("abc");
		 String s2=new String("abc");
		 
		 System.out.println(s1==s2);
		 
		 //判断内容是否相等，用equals方法
		 System.out.println(s1.equals(s2));
		 
	 }
	 @Test
	 public void test12() {
		 Employee e1=new Employee();
		 Employee e2=new Employee();
		 Employee e3=e1;
		 
		 String s=new String ();
		 System.out.println(e1.equals(s));
		 
		 System.out.println(e1.equals(e2));
		 
		 System.out.println(e1.equals(e1));
		 System.out.println(e1.equals(e3));
		 
		 
		 
	 }
	 
}
